<template>
	<el-drawer
		v-model="drawerVisible"
		@closed="cancelFrom(ruleFormRef)"
		:destroy-on-close="true"
		:close-on-click-modal="false"
		size="50%"
		:title="`${drawerProps.title}赛事项目`"
	>
		<el-form
			ref="ruleFormRef"
			:model="ruleForm"
			:rules="rules"
			label-width="180px"
			label-position="left"
			class="demo-ruleForm"
			status-icon
		>
			<el-form-item label="比赛项目：" prop="projectId">
				<el-cascader v-model="ruleForm.projectId" :options="options" @change="handleChange" />
			</el-form-item>
			<el-form-item label="比赛类型：" prop="gameType">
				<el-radio-group @change="handleGameTypeChange" :disabled="drawerProps.title == '编辑'" v-model="ruleForm.gameType">
					<el-radio :label="1">团队接力赛</el-radio>
					<el-radio :label="2">单人赛</el-radio>
				</el-radio-group>
			</el-form-item>
			<el-form-item label="比赛开始时间：" prop="gameBeginTime">
				<el-date-picker
					value-format="YYYY-MM-DD HH:mm:ss"
					:disabledDate="gameBeginTimeDisablesDate"
					v-model="ruleForm.gameBeginTime"
					type="datetime"
					placeholder="开始时间"
				/>
			</el-form-item>
			<el-form-item label="比赛结束时间：" prop="gameEndTime">
				<el-date-picker
					value-format="YYYY-MM-DD HH:mm:ss"
					v-model="ruleForm.gameEndTime"
					:disabledDate="gameBeginTimeDisablesDate"
					type="datetime"
					placeholder="结束时间"
				/>
			</el-form-item>
			<el-form-item label="预赛比赛时长：" prop="gameTime">
				<el-input style="width: auto" placeholder="请输入" v-model.number="ruleForm.gameTime" type="text">
					<template #append> 分钟 </template>
				</el-input>
			</el-form-item>
			<el-form-item label="决赛比赛时长：" prop="finalsGameTime">
				<el-input style="width: auto" placeholder="请输入" v-model.number="ruleForm.finalsGameTime" type="text">
					<template #append> 分钟 </template>
				</el-input>
			</el-form-item>
			<div v-if="ruleForm.gameType == 1">
				<el-form-item label="* 团队限制：">
					<div style="display: flex">
						<el-input maxlength="4" v-model.number="ruleForm.sensorsMaxNum" type="text" placeholder="请输入数字">
							<template #prepend> 最多 </template>
							<template #append> 感应器 </template>
						</el-input>
						，
						<el-input maxlength="4" v-model.number="ruleForm.teamMaxUserNum" type="text" placeholder="请输入数字">
							<template #prepend> 团队最多 </template>
							<template #append> 人 </template>
						</el-input>
					</div>
					<!-- <p style="color: #d8d8d8">不填则默认不限制</p> -->
				</el-form-item>
				<p style="margin-left: 180px; font-size: 14px; color: #d8d8d8">不填则默认不限制</p>
				<el-form-item label="报名限制：" prop="signUpLimit">
					<el-radio-group v-model.number="ruleForm.signUpLimit">
						<el-radio :label="1">允许单人报名</el-radio>
						<el-radio :label="0">不允许单人报名</el-radio>
					</el-radio-group>
				</el-form-item>
				<el-form-item label="组队限制：" prop="groupLimit">
					<el-radio-group v-model.number="ruleForm.groupLimit">
						<el-radio :label="1">允许现场组队</el-radio>
						<el-radio :label="0">不允许现场组队</el-radio>
					</el-radio-group>
				</el-form-item>
			</div>
			<!-- 待测试 -->
			<div v-else>
				<el-form-item label="报名人数限制：" prop="maxEmployeeNum">
					<el-input maxlength="4" v-model.number="ruleForm.maxEmployeeNum" type="text" placeholder="请输入报名人数限制">
						<template #prepend> 报名最多 </template>
						<template #append> 人 </template>
					</el-input>
				</el-form-item>
				<el-form-item v-if="drawerProps.row.chargeType == 1" label="项目折扣规则：" prop="discount">
					<el-space>
						<el-input
							placeholder="请输入折扣"
							v-model.number="ruleForm.discount"
							:disabled="!ruleForm.isDiscount || ruleForm.isFree"
							type="text"
						/>
						<el-checkbox
							style="margin-left: 15px"
							@change="handleDiscountChange"
							v-model="ruleForm.isDiscount"
							label="参与折扣"
							size="large"
						/>
					</el-space>
				</el-form-item>
			</div>
			<el-form-item v-if="drawerProps.row.chargeType == 1" label="报名费用：" prop="costMoney">
				<el-space>
					<el-input placeholder="请输入" v-model="ruleForm.costMoney" :disabled="ruleForm.isFree" type="text">
						<template #append>
							<el-select style="width: 120px" v-model.number="ruleForm.costType" placeholder="元/人">
								<el-option label="元/人" :value="1" />
								<el-option v-if="ruleForm.gameType == 1" label="元/队" :value="2" />
							</el-select>
						</template>
					</el-input>
					<el-checkbox
						@change="handleIsFreeChange"
						style="margin-left: 15px"
						v-model="ruleForm.isFree"
						label="免费"
						size="large"
					/>
				</el-space>
			</el-form-item>
			<el-form-item label="* 所属赛事：">
				<el-input style="width: auto" v-model="drawerProps.row.name" type="text" disabled> </el-input>
				<el-input v-if="false" v-model="ruleForm.name"></el-input>
			</el-form-item>
			<el-form-item label="* 举办城市：">
				<el-input disabled style="width: auto" v-model="drawerProps.row.city"></el-input>
			</el-form-item>
			<el-form-item label="项目举办地点：" prop="address">
				<el-input placeholder="请输入" maxlength="50" v-model="ruleForm.address" type="text" />
			</el-form-item>
			<el-form-item label="项目举办场馆：" prop="stadium">
				<el-input placeholder="请输入" maxlength="50" v-model="ruleForm.stadium" type="text" />
			</el-form-item>
			<!-- 需要高德地图 -->
			<el-form-item label="项目比赛详细地址：" prop="detailsAddress">
				<el-input placeholder="请点击选择" @focus="showMap" v-model="ruleForm.detailsAddress" type="text" />
			</el-form-item>
			<el-form-item label="项目咨询人：" prop="consultant">
				<el-input placeholder="请输入" maxlength="50" v-model="ruleForm.consultant" type="text" />
			</el-form-item>
			<el-form-item label="项目咨询人电话：" prop="telePhone">
				<el-input maxlength="11" placeholder="请输入" v-model.number="ruleForm.telePhone" type="text" />
			</el-form-item>
			<el-descriptions title="成绩计算规则" :column="1" border>
				<template #extra>
					<el-button @click="gradeBulrs.handleShowModle(1)">选择计算规则</el-button>
				</template>
				<el-descriptions-item label="计算规则:" label-class-name="description-label" label-align="left">
					{{ gradeBulrs.gridContent || "（请选择）" }}
				</el-descriptions-item>
			</el-descriptions>
			<el-descriptions style="margin-top: 15px" title="成绩惩罚规则" :column="1" border>
				<template #extra>
					<el-button @click="gradeBulrs.handleShowModle(0)">选择惩罚规则</el-button>
				</template>
				<el-descriptions-item label-class-name="description-label" label="惩罚规则:" label-align="left">
					{{ gradeBulrs.punishContent || "（请选择）" }}
				</el-descriptions-item>
			</el-descriptions>
			<el-form-item label="是否手动打分：" prop="state">
				<el-radio-group v-model="ruleForm.isScore">
					<el-radio :label="1">是</el-radio>
					<el-radio :label="0">否</el-radio>
				</el-radio-group>
			</el-form-item>
			<el-form-item v-if="ruleForm.state < 2" label="状态：" prop="state">
				<el-radio-group v-model="ruleForm.state">
					<el-radio :label="1">启用</el-radio>
					<el-radio :label="0">禁用</el-radio>
				</el-radio-group>
			</el-form-item>
			<el-form-item v-else label="状态：" prop="state">
				<el-radio-group disabled v-model="ruleForm.state">
					<el-radio :label="ruleForm.state">{{
						ruleForm.state == 2
							? "正在报名"
							: ruleForm.state == 3
							? "待分组"
							: ruleForm.state == 4
							? "待签到"
							: ruleForm.state == 5
							? "正在比赛"
							: "比赛结束"
					}}</el-radio>
				</el-radio-group>
			</el-form-item>
		</el-form>
		<el-dialog @closed="gradeBulrs.handleCloseClick" v-model="gradeBulrs.modelShow" width="70%">
			<template #header>
				<p>请选择{{ gradeBulrs.type == 1 ? "成绩计算" : "惩罚" }}规则</p>
			</template>
			<el-table border :data="gradeBulrs.type == 1 ? gradeBulrs.gridRuls : gradeBulrs.punishRules">
				<el-table-column property="name" label="规则名称" width="200" />
				<!-- <el-table-column property="applyProject" width="150" label="所属项目" /> -->
				<el-table-column property="type" width="150" label="规则类型">
					<template #default="scope">
						{{ scope.row.type == 0 ? "成绩计算规则" : "惩罚规则" }}
					</template>
				</el-table-column>
				<el-table-column property="content" width="400" label="规则内容" />
				<el-table-column fixed="right" label="操作" align="center">
					<template #default="scope">
						<el-radio v-model="gradeBulrs.isChecked" :label="scope.$index" size="large">{{ "" }}</el-radio>
					</template>
				</el-table-column>
			</el-table>
			<template #footer>
				<span class="dialog-footer">
					<el-button @click="gradeBulrs.handleCloseClick">取消</el-button>
					<el-button type="primary" @click="gradeBulrs.handleSubmit"> 确定 </el-button>
				</span>
			</template>
		</el-dialog>
		<BaiduMapSelect :longitude="lng" :latitude="lat" ref="bmapAddressSelect" @confirm-map-address="confirmMapAddress">
		</BaiduMapSelect>
		<template #footer>
			<el-button @click="cancelFrom(ruleFormRef)">取消</el-button>
			<el-button type="primary" @click="handleSubmit">确定</el-button>
		</template>
	</el-drawer>
</template>

<script setup lang="ts" name="UserDrawer">
import { ElMessage, FormInstance, FormRules } from "element-plus";
import { ref, watch, reactive, nextTick } from "vue";
import competitionProject from "@/api/modules/competitionProject";
import competitionRuleInfoApi from "@/api/modules/competitionRuleInfo";
import projectApi from "@/api/modules/project";
import BaiduMapSelect from "@/components/BaiduMapSelect/index.vue";
import { ruleForm, Option, DrawerProps } from "../interface";
const ruleFormRef = ref<FormInstance>();
const drawerVisible = ref(false);
const drawerProps = ref<DrawerProps>({
	isView: false,
	title: "",
	id: "",
	row: {}
});
// 地图经纬度
const lng = ref<number>(-1);
const lat = ref<number>(-1);
// 获取百度地图弹窗组件实例
const bmapAddressSelect = ref();
// 项目多级选项
const options = ref<Array<Option>>([]);
const getProjectlist = async () => {
	//获取多级联动数据包
	let { result } = await competitionProject.GetProjectTypeListApi();
	options.value = result.data.map((item: any) => ({
		value: item.id,
		label: item.name,
		children: []
	}));
	options.value.forEach(async (item: any) => {
		let { result } = await projectApi.GetProjectInfoApi({
			id: item.value
		});
		if (result.code != 200) return;
		item.children = [
			...result.data.map((val: any) => {
				return {
					value: val.id,
					label: val.name
				};
			})
		];
	});
};
getProjectlist();
const handleChange = async (value: any) => {
	if (value.length < 2) {
		ruleForm.value.projectId = [];
		ElMessage.warning("此选项是比赛项目类型，请选择比赛项目！");
		return false;
	}
	let projectName: string = "";
	let newArr: any = options.value.filter((item: Option) => {
		return value[0] === item.value;
	});
	JSON.parse(JSON.stringify(newArr))[0].children.forEach((item: any) => {
		if (item.value === value[1]) {
			projectName = item.label;
		}
	});
	ruleForm.value.name = projectName;
	ruleForm.value.punishmentRule = "";
	ruleForm.value.calculationRule = "";
	gradeBulrs.gridContent = "";
	gradeBulrs.punishContent = "";
};
// 表单校验规则
const rules = reactive<FormRules>({
	projectId: [
		{
			required: true,
			message: "请选择比赛项目！",
			trigger: "change"
		}
	], //项目选择
	gameType: [
		{
			required: true,
			message: "请选择比赛类型！",
			trigger: "blur"
		}
	], //比赛类型
	gameBeginTime: [
		{
			required: true,
			message: "请选择比赛开始时间！",
			trigger: "change"
		}
	], //比赛开始时间
	gameEndTime: [
		{
			required: true,
			message: "请选择比赛结束时间！",
			trigger: "blur"
		}
	],
	finalsGameTime: [
		{
			required: true,
			message: "请选择比赛结束时间！",
			trigger: "blur"
		}
	],
	costMoney: [
		{
			required: true,
			message: "请输入报名费用或则是否免费！",
			trigger: "blur"
		}
	],
	discount: [
		{
			required: true,
			message: "请输入折扣规则！",
			trigger: "blur"
		}
	],
	maxEmployeeNum: [
		{
			required: true,
			message: "请输入报名最大人数！",
			trigger: "blur"
		}
	],
	gameTime: [
		{
			required: true,
			message: "比赛时长不能为0！",
			trigger: "blur"
		}
	], //比赛时间
	sensorsMaxNum: [
		{
			required: true,
			message: "最多传感器不能为0！",
			trigger: "blur"
		}
	], //传感器最大数量
	teamMaxUserNum: [
		{
			required: true,
			message: "团队最大成员数量不能为0！",
			trigger: "blur"
		}
	], //团队最大队员数量
	signUpLimit: [
		{
			required: true,
			message: "报名限制为必选项！",
			trigger: "blur"
		}
	], //报名限制
	groupLimit: [
		{
			required: true,
			message: "组队限制为必选项！",
			trigger: "change"
		}
	], //组队限制
	address: [
		{
			required: true,
			message: "项目举办地为必填项！",
			trigger: "blur"
		}
	], //地址
	stadium: [
		{
			required: true,
			message: "项目举办场馆为必填项！",
			trigger: "blur"
		}
	], //场馆
	detailsAddress: [
		{
			required: true,
			message: "项目比赛详细地址为必填项！",
			trigger: "change"
		}
	], //详细地址
	consultant: [
		{
			required: true,
			message: "咨询人不能为空！",
			trigger: "blur"
		}
	], //咨询人
	telePhone: [
		{
			required: true,
			message: "咨询人电话不能为空！",
			trigger: "blur"
		},
		{
			pattern: /^(13[0-9]|14[1|4|5|6|7|8|9]|15[0|1|2|3|5|6|7|8|9]|17[2|3|5|6|7|8]|18[0-9]|19[1|8|9])\d{8}$/,
			message: "手机号格式不正确"
		}
	], //咨询人电话
	state: [
		{
			required: true,
			message: "状态为必填项！",
			trigger: "change"
		}
	]
});
// 表单数据
const ruleForm = ref<ruleForm>({
	id: null,
	competitionId: drawerProps.value.row.id, //比赛id
	name: drawerProps.value.row.name, //项目名称
	projectId: "", //项目选择
	gameType: 1, //比赛类型
	calculationRule: "", //计算规则
	punishmentRule: "", //惩罚规则
	gameBeginTime: null, //比赛开始时间
	gameEndTime: null, //比赛结束时间
	gameTime: 0, //比赛时间
	finalsGameTime: 0, //比赛结束时间
	sensorsMaxNum: 0, //传感器最大数量
	teamMaxUserNum: 0, //团队最大队员数量
	signUpLimit: 1, //报名限制
	groupLimit: 1, //组队限制
	costMoney: 0, //收费金额
	discount: 10,
	isDiscount: true,
	costType: 1, //收费类型
	isFree: false, //是否免费
	address: "", //地址
	stadium: "", //场馆
	detailsAddress: "", //详细地址
	point: "", //
	consultant: "", //咨询人
	telePhone: "", //咨询人电话
	state: 1, //状态
	isEnable: 1, //是否启用
	maxEmployeeNum: 0,
	isScore: 0
	// id: null,
	// competitionId: route.query.competitionId as string, //比赛id,
	// name: "",
	// projectId: "",
	// gameType: 2,
	// calculationRule: "",
	// punishmentRule: "",
	// gameBeginTime: null,
	// gameEndTime: null,
	// gameTime: 5,
	// sensorsMaxNum: 0,
	// teamMaxUserNum: 0,
	// signUpLimit: 1,
	// groupLimit: 1,
	// costMoney: 0,
	// costType: 1,
	// isFree: true,
	// address: "弥勒市红河水乡",
	// stadium: "红河水乡公园",
	// detailsAddress: "红河水乡",
	// point: "24.40502980693296,103.43260215069185",
	// consultant: "赵波",
	// telePhone: "13708708662",
	// state: 1,
	// isEnable: 1,
	// maxEmployeeNum: 500
});
//成绩计算规则
const gradeBulrs = reactive({
	gridRuls: [] as any, //成绩计算规则表格
	punishRules: [] as any, //惩罚规则表格
	modelShow: false, //选择规则弹框
	isChecked: -1, //表格选中下标
	gridContent: "", //选中后得计算规则
	punishContent: "", //选中后得惩罚规则
	type: 1, //区别成绩计算规则害是惩罚规则
	handleShowModle: async (type: number) => {
		let projectId = ruleForm.value.projectId[1];
		if (!projectId) {
			ElMessage.warning("请选择项目后再操作！");
			return;
		}
		gradeBulrs.type = type;
		let index: number = -1;
		if (type === 1) {
			let res = await competitionProject.GetRuleListApi(0, projectId);
			if (!res.result.data.length) {
				ElMessage.warning("此项目暂无规则，请到规则管理添加后在操作！");
				return;
			}
			gradeBulrs.gridRuls = res.result.data;
			gradeBulrs.modelShow = true;
			if (!gradeBulrs.gridContent) {
				//没有成绩规则
				gradeBulrs.isChecked = -1;
				return;
			}
			//有成绩规则
			gradeBulrs.gridRuls.forEach((item: any, idx: number) => {
				if (item.id == ruleForm.value.calculationRule) {
					index = idx;
				}
			});
			console.log(ruleForm.value.calculationRule, gradeBulrs.gridRuls);
			gradeBulrs.isChecked = index;
			return false;
		}
		let res = await competitionProject.GetRuleListApi(1, projectId);
		if (!res.result.data.length) {
			ElMessage.warning("此项目暂无规则，请到规则管理添加后在操作！");
			return;
		}
		gradeBulrs.punishRules = res.result.data;
		gradeBulrs.modelShow = true;
		if (!gradeBulrs.punishContent) {
			//没有惩罚规则
			gradeBulrs.isChecked = -1;
			return false;
		}
		//有惩罚规则
		gradeBulrs.punishRules.forEach((item: any, idx: number) => {
			if (item.id == ruleForm.value.punishmentRule) {
				index = idx;
			}
		});
		gradeBulrs.isChecked = index;
	},
	handleSubmit: () => {
		if (!gradeBulrs.type) {
			if (gradeBulrs.isChecked == -1) {
				ElMessage.warning("请选择惩罚规则！");
				return false;
			}
			gradeBulrs.punishContent = gradeBulrs.punishRules[gradeBulrs.isChecked].content as never;
			ruleForm.value.punishmentRule = gradeBulrs.punishRules[gradeBulrs.isChecked].id;
			gradeBulrs.modelShow = false;
		} else {
			if (gradeBulrs.isChecked == -1) {
				ElMessage.warning("请选择惩罚规则！");
				return false;
			}
			ruleForm.value.calculationRule = gradeBulrs.gridRuls[gradeBulrs.isChecked].id;
			gradeBulrs.gridContent = gradeBulrs.gridRuls[gradeBulrs.isChecked].content as never;
			gradeBulrs.modelShow = false;
		}
	},
	handleCloseClick: () => {
		gradeBulrs.modelShow = false;
		gradeBulrs.gridRuls = [];
		gradeBulrs.punishRules = [];
	}
});
// 编辑情况下初始化页面数据
const init = async () => {
	if (!drawerProps.value.id) return;
	let res = await competitionProject.GetCompetitionPorjectDetailsByIdApi(drawerProps.value.id);
	let { data } = res.result;
	ruleForm.value = { ...data };
	ruleForm.value.projectId = [data.projectTypeId, data.projectId];
	let calculationRule = await competitionRuleInfoApi.CompetitionRuleInfoDetailsApi(data.calculationRule);
	gradeBulrs.gridContent = calculationRule.result.data.content;
	let punishmentRule = await competitionRuleInfoApi.CompetitionRuleInfoDetailsApi(data.punishmentRule);
	gradeBulrs.punishContent = punishmentRule.result.data.content;
	let arr = data.point.split(",");
	lng.value = parseFloat(arr[1]);
	lat.value = parseFloat(arr[0]);
};
const showMap = () => {
	//点击弹出地图组件
	nextTick(() => {
		bmapAddressSelect.value.show();
	});
};
/** 确认地图地址 */
const confirmMapAddress = (addressInfo: Array<any>) => {
	let { latitude, longitude } = addressInfo[0];
	ruleForm.value.point = `${latitude},${longitude}`;
	ruleForm.value.detailsAddress = addressInfo[1];
	lng.value = longitude;
	lat.value = latitude;
};
// 切换赛事类型
const handleGameTypeChange = (val: any) => {
	if (val == 1) {
		ruleForm.value.maxEmployeeNum = 0;
		return;
	}
	ruleForm.value.teamMaxUserNum = 0;
	ruleForm.value.sensorsMaxNum = 0;
	ruleForm.value.discount = 10;
	ruleForm.value.isDiscount = true;
};
// 监听用户选择时间一定要符合规定
watch(
	() => ruleForm.value.gameEndTime,
	() => {
		if (!ruleForm.value.gameBeginTime || !ruleForm.value.gameEndTime) return;
		if (new Date(ruleForm.value.gameEndTime).getTime() <= new Date(ruleForm.value.gameBeginTime).getTime()) {
			ElMessage.error("结束时间必须大于开始时间！！！");
		}
	}
);
const gameBeginTimeDisablesDate = (time: any) => {
	const _minTime = new Date(drawerProps.value.row.matchBeginTime).getTime();
	const _maxTime = new Date(drawerProps.value.row.matchEndTime).getTime();
	return time.getTime() < _minTime || time.getTime() > _maxTime;
};
watch(
	() => drawerVisible.value,
	val => {
		if (!val) return;
		init();
	}
);
const handleDiscountChange = (val: boolean) => {
	if (!val) {
		ruleForm.value.discount = 10;
		return;
	}
};
const handleIsFreeChange = (val: boolean) => {
	if (!val) return;
	ruleForm.value.discount = 10;
	ruleForm.value.costMoney = 0;
	ruleForm.value.isDiscount = false;
};
// 接收父组件传过来的参数
const acceptParams = (params: DrawerProps) => {
	console.log(params);
	drawerProps.value = params;
	drawerVisible.value = true;
};
const cancelFrom = (formEl: FormInstance | undefined) => {
	if (!formEl) return;
	formEl.resetFields();
	gradeBulrs.gridRuls = [];
	gradeBulrs.punishRules = [];
	ruleForm.value = {
		id: null,
		competitionId: drawerProps.value.row.id, //比赛id
		name: drawerProps.value.row.name, //项目名称
		projectId: "", //项目选择
		gameType: 1, //比赛类型
		calculationRule: "", //计算规则
		punishmentRule: "", //惩罚规则
		gameBeginTime: null, //比赛开始时间
		gameEndTime: null, //比赛结束时间
		gameTime: 0, //比赛时间
		finalsGameTime: 0,
		sensorsMaxNum: 0, //传感器最大数量
		teamMaxUserNum: 0, //团队最大队员数量
		signUpLimit: 1, //报名限制
		groupLimit: 1, //组队限制
		costMoney: 0, //收费金额
		discount: 10,
		isDiscount: false,
		costType: 1, //收费类型
		isFree: false, //是否免费
		address: "", //地址
		stadium: "", //场馆
		detailsAddress: "", //详细地址
		point: "", //
		consultant: "", //咨询人
		telePhone: "", //咨询人电话
		state: 1, //状态
		isEnable: 1, //是否启用
		maxEmployeeNum: 0,
		isScore: 0
	};
	gradeBulrs.gridContent = "";
	gradeBulrs.punishContent = "";
	drawerVisible.value = false;
};
const handleSubmit = () => {
	ruleFormRef.value!.validate(async valid => {
		if (!valid) return;
		try {
			if (!ruleForm.value.calculationRule || !ruleForm.value.punishmentRule) {
				ElMessage.error("请选择规则！");
				return;
			}
			if (new Date(ruleForm.value.gameEndTime!).getTime() <= new Date(ruleForm.value.gameBeginTime!).getTime()) {
				ElMessage.error("结束时间必须大于开始时间！！！");
				return;
			}
			ruleForm.value.projectId = ruleForm.value.projectId[1];
			ruleForm.value.competitionId = drawerProps.value.row.id;
			await competitionProject.EditCompetitionProjecApi(ruleForm.value);
			ElMessage.success({ message: `${drawerProps.value.title}赛事项目成功！` });
			drawerProps.value.getTableList!();
			drawerVisible.value = false;
		} catch (error) {
			console.log(error);
		}
	});
};
defineExpose({
	acceptParams
});
</script>
<style lang="scss" scoped>
.title {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin: 30px 0;
	span {
		position: relative;
		font-size: 22px;
		line-height: 22px;
		color: #000000;
		text-align: center;
		&::before {
			position: absolute;
			left: -8px;
			width: 2px;
			height: 100%;
			content: "";
			background-color: blue;
		}
	}
}
</style>
<style>
.description-label {
	width: 180px;
}
</style>
